#include <bits/stdc++.h>
// 2024/08/08
// tag: 模拟
using namespace std;

int carpet[100001][4];

signed main()
{
    int n, x, y;
    cin >> n;
    // 输入n个地毯的坐标
    for (int i = 0; i < n; i++)
        cin >> carpet[i][0] >> carpet[i][1] >> carpet[i][2] >> carpet[i][3];
    cin >> x >> y;

    int ans = -1;

    // 遍历n个地毯，判断是否有地毯覆盖(x, y)点
    for (int i = 0; i < n; i++)
        if (carpet[i][0] <= x && carpet[i][1] <= y && carpet[i][0] + carpet[i][2] >= x && carpet[i][1] + carpet[i][3] >= y)
            ans = i + 1;
    cout << ans << endl;
    return 0;
}